﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AiFrame.InterfaceLib.Data.Access.NHibernateAccess;
using AiFrameDemo.Lib.Model;
using NHibernate;

namespace AiFrameDemo.Contacts.Core.DataStore
{
    class NHibernateContactStore: BasicDaoNHibernate<Contact, Guid>, IContactStore
    {
        public NHibernateContactStore(ISession session) : base(session)
        {
        }

        public IList<Contact> FindByCustomerID(Guid id)
        {
            string queryString = "from Contact c where c.Customer.ID = :customerID";
            IQuery query = _session.CreateQuery(queryString);
            query.SetGuid("customerID", id);

            return query.List<Contact>();
        }
    }
}
